﻿package view.popup
{
    import cmd.*;
    import com.sh.game.global.*;
    import com.sh.game.util.*;
    import flash.events.*;
    import flash.text.*;
    import manager.*;
    import morn.core.components.*;

    public class NewSureDownPopUI extends View implements IDialogUI
    {
        public var closeBtn:Button;
        public var sureBtn:Button;
        public var checkbox:CheckBox;
        protected var uiXML:XML;
        private var toptext:TextField;
        private var middletext:TextField;
        private var dectext:TextField;
        private var _armid:int;
        private var _index:int;
        private var _itemid:int;
        private var cfgitem:Object;

        public function NewSureDownPopUI()
        {
            this.uiXML = <View>r
n	t	t	t  <Image url=""png.common.s9_tishi"" x=""0"" y=""0"" width=""300"" height=""185"" sizeGrid=""5,16,5,29""/>r
n	t	t	t  <Button skin=""png.common.btn_close_normal"" x=""273"" y=""0"" var=""closeBtn""/>r
n	t	t	t  <Button skin=""png.common.btn_usual_normal"" x=""110"" y=""144"" var=""sureBtn"" labelStroke=""1""/>r
n	t	t	t  <CheckBox skin=""png.common.checkbox"" x=""21"" y=""103"" var=""checkbox""/>r
n	t	t	t  <Image url=""png.common.s9_fenline"" x=""12"" y=""70"" width=""277"" sizeGrid=""5,16,5,29""/>r
n	t	t	t</View>")("<View>
			  <Image url="png.common.s9_tishi" x="0" y="0" width="300" height="185" sizeGrid="5,16,5,29"/>
			  <Button skin="png.common.btn_close_normal" x="273" y="0" var="closeBtn"/>
			  <Button skin="png.common.btn_usual_normal" x="110" y="144" var="sureBtn" labelStroke="1"/>
			  <CheckBox skin="png.common.checkbox" x="21" y="103" var="checkbox"/>
			  <Image url="png.common.s9_fenline" x="12" y="70" width="277" sizeGrid="5,16,5,29"/>
			</View>;
            this.cfgitem = ConfigDictionary.data.item;
            return;
        }// end function

        override protected function createChildren() : void
        {
            createView(this.uiXML);
            this.init();
            return;
        }// end function

        override protected function initialize() : void
        {
            super.initialize();
            return;
        }// end function

        public function init() : void
        {
            var _loc_1:TextFormat = null;
            this.visible = false;
            this.x = GlobalLayer.instance.root.stage.stageWidth - this.width >> 1;
            this.y = GlobalLayer.instance.root.stage.stageHeight - this.height >> 1;
            _loc_1 = new TextFormat("宋体", 12);
            this.toptext = new TextField();
            this.toptext.x = 18;
            this.toptext.y = 42;
            this.toptext.width = 280;
            this.toptext.height = 20;
            this.toptext.defaultTextFormat = _loc_1;
            this.toptext.text = "确定要摘除该宝石？";
            this.toptext.textColor = MColor.New5;
            this.toptext.autoSize = TextFieldAutoSize.LEFT;
            this.addChild(this.toptext);
            this.middletext = new TextField();
            this.middletext.x = 18;
            this.middletext.y = 81;
            this.middletext.width = 240;
            this.middletext.height = 20;
            this.middletext.defaultTextFormat = _loc_1;
            this.middletext.text = "防止宝石降级";
            this.middletext.textColor = MColor.New5;
            this.middletext.autoSize = TextFieldAutoSize.LEFT;
            this.dectext = new TextField();
            this.dectext.x = 40;
            this.dectext.y = 103;
            this.dectext.width = 230;
            this.dectext.height = 40;
            this.dectext.defaultTextFormat = new TextFormat("宋体", 12, null, null, null, null, null, null, null, null, null, null, 3);
            this.dectext.textColor = MColor.New5;
            this.dectext.wordWrap = true;
            this.dectext.multiline = true;
            this.checkbox.selected = false;
            this.checkbox.visible = false;
            this.checkbox.addEventListener(MouseEvent.CLICK, this.onClicked);
            this.sureBtn.label = "确认摘除";
            this.sureBtn.labelFont = "宋体";
            this.sureBtn.labelColors = "0xb29a6c, 0xb29a6c, 0xb29a6c";
            this.sureBtn.addEventListener(MouseEvent.CLICK, this.onSureDrop);
            this.closeBtn.addEventListener(MouseEvent.CLICK, this.onClose);
            this.addEventListener(MouseEvent.MOUSE_DOWN, this.onDown);
            GlobalLayer.instance.root.addEventListener(Event.RESIZE, this.resizeHandler);
            return;
        }// end function

        private function onSureDrop(event:MouseEvent) : void
        {
            PluginManager.instance.sendToServer("qianghua", CMDQiangHua.ZhaiChu, {itemid:this._itemid, index:int((this._index - 1)), armid:this._armid, flag:this.checkbox.selected});
            this.close();
            return;
        }// end function

        private function onClicked(event:MouseEvent) : void
        {
            this.checkbox.removeEventListener(MouseEvent.CLICK, this.onClicked);
            var _loc_2:* = event.currentTarget as CheckBox;
            this.checkbox.selected = false;
            _loc_2.selected = true;
            this.checkbox.addEventListener(MouseEvent.CLICK, this.onClicked2);
            return;
        }// end function

        private function onClicked2(event:MouseEvent) : void
        {
            this.checkbox.removeEventListener(MouseEvent.CLICK, this.onClicked2);
            var _loc_2:* = event.currentTarget as CheckBox;
            this.checkbox.selected = true;
            _loc_2.selected = false;
            this.checkbox.addEventListener(MouseEvent.CLICK, this.onClicked);
            return;
        }// end function

        public function show(param1:Object) : void
        {
            this._armid = param1[0];
            this._index = param1[1];
            this._itemid = param1[2];
            var _loc_2:* = this.cfgitem[this._itemid].level;
            this.visible = true;
            return;
        }// end function

        private function onClose(event:MouseEvent) : void
        {
            this.close();
            return;
        }// end function

        public function close() : void
        {
            this.visible = false;
            return;
        }// end function

        private function onDown(event:MouseEvent) : void
        {
            event.stopImmediatePropagation();
            return;
        }// end function

        private function resizeHandler(event:Event) : void
        {
            this.x = GlobalLayer.instance.root.stage.stageWidth - this.width >> 1;
            this.y = GlobalLayer.instance.root.stage.stageHeight - this.height >> 1;
            return;
        }// end function

    }
}
